package com.zxy.controller;


import com.zxy.common.ResultData;
import com.zxy.service.ICardService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * 一卡通申请
 * </p>
 *
 * @author Zxy
 * @since 2021-05-11
 */
@RestController
@RequestMapping("/card")
@AllArgsConstructor
public class CardController {

    private final ICardService cardService;

    @GetMapping("/apply")
    public ResultData applyCard(String name) {
        return cardService.cardApply(name);
    }

    @GetMapping("/check")
    public ResultData checkApply(@RequestParam(name = "name") String name) {
        Boolean apply = cardService.checkApply(name);
        if (apply) {
            return ResultData.success("数据库中没有找到信息，您可以申请");
        } else {
            return ResultData.fail("您已经申请，请勿重复申请");
        }
    }
}
